package org.springframework.web.servlet.handler;

import java.util.LinkedHashMap;

import org.springframework.web.method.HandlerMethod;

public class EngineMappingHandlerMethodHashMap<K> extends LinkedHashMap<K, HandlerMethod>{
	
	@Override
	public HandlerMethod get(Object key) {
		HandlerMethod method = EngineMappingRegistrationCache.getInstance().getMappingLookup().get(key);
		if(method != null && method.getClassLoader() != null && !method.getClassLoader().equals(Thread.currentThread().getContextClassLoader())){
			Thread.currentThread().setContextClassLoader(method.getClassLoader());
		}
		return method;
	}
	@Override
	public HandlerMethod remove(Object key) {
		return EngineMappingRegistrationCache.getInstance().getMappingLookup().remove(key);
	}

}
